home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LTP_SelectKeys.c < prev    next >
C/C++ Source or Header  |  1996-08-22  |  3KB  |  171 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #ifdef DO_PICKSHORTCUTS
  15. VOID
  16. LTP_SelectKeys(LayoutHandle *handle,ObjectNode *group)
  17. {
  18.     LONG         bunch;
  19.     ObjectNode    *node;
  20.     ULONG         page;
  21.     STRPTR        *lines;
  22.  
  23.     SCANPAGE(group,node,page)
  24.     {
  25.         bunch = 0;
  26.         lines = NULL;
  27.  
  28.         switch(node->Type)
  29.         {
  30.             case GROUP_KIND:
  31.  
  32.                 LTP_SelectKeys(handle,node);
  33.                 break;
  34.  
  35.             case TEXT_KIND:
  36.  
  37.                 if(!node->Special.Text.UsePicker)
  38.                     break;
  39.  
  40.             case PASSWORD_KIND:
  41.             case STRING_KIND:
  42.  
  43.                 if(node->Type != TEXT_KIND && node->Special.String.UsePicker)
  44.                     bunch = 255;
  45.  
  46.             case BUTTON_KIND:
  47.  
  48.                 if(node->Type == BUTTON_KIND)
  49.                 {
  50.                     if(!node->NoKey && node->Special.Button.Lines)
  51.                         lines = node->Special.Button.Lines;
  52.                 }
  53.  
  54.             case BOOPSI_KIND:
  55.             case CHECKBOX_KIND:
  56.             case INTEGER_KIND:
  57.  
  58.                 bunch++;
  59.  
  60.             case LISTVIEW_KIND:
  61.             case MX_KIND:
  62.             case CYCLE_KIND:
  63.             case PALETTE_KIND:
  64.             case SCROLLER_KIND:
  65.             case SLIDER_KIND:
  66. #if defined(DO_POPUP_KIND) && defined(DO_BOOPSI_KIND)
  67.             case POPUP_KIND:
  68. #endif
  69. #if defined(DO_TAB_KIND) && defined(DO_BOOPSI_KIND)
  70.             case TAB_KIND:
  71. #endif
  72. #ifdef DO_LEVEL_KIND
  73.             case LEVEL_KIND:
  74. #endif    /* DO_LEVEL_KIND */
  75. #ifdef DO_TAPEDECK_KIND
  76.             case TAPEDECK_KIND:
  77. #endif    /* DO_TAPEDECK_KIND */
  78.  
  79.                 bunch++;
  80.  
  81.                 if(node->Label && !node->Key && !node->NoKey)
  82.                 {
  83.                     LONG    i,len,code,glyph;
  84.                     STRPTR    label;
  85.  
  86.                     do
  87.                     {
  88.                         if(lines)
  89.                         {
  90.                             if(!(label = *lines++))
  91.                                 break;
  92.                         }
  93.                         else
  94.                             label = node->Label;
  95.  
  96.                         len = strlen(label);
  97.  
  98.                         for(i = 0 ; i < len ; i++)
  99.                         {
  100.                             glyph    = ToLower(label[i]);
  101.                             code    = -1;
  102.  
  103.                             switch(bunch)
  104.                             {
  105.                                 case 1:    // Support increment & decrement
  106.  
  107.                                     if(LTP_Keys[0][glyph] && LTP_Keys[1][glyph])
  108.                                         code = LTP_Keys[0][glyph];
  109.  
  110.                                     break;
  111.  
  112.                                         // Any one will do
  113.  
  114.                                 case 2:
  115.  
  116.                                     if(LTP_Keys[0][glyph])
  117.                                         code = LTP_Keys[0][glyph];
  118.                                     else
  119.                                     {
  120.                                         if(LTP_Keys[1][glyph] && LTP_Keys[0][glyph])
  121.                                         {
  122.                                             if(ToLower(LTP_Keys[1][glyph]) == glyph)
  123.                                                 code = LTP_Keys[0][glyph];
  124.                                         }
  125.                                     }
  126.  
  127.                                     break;
  128.                             }
  129.  
  130.                             if(code != -1 && !handle->Keys[code])
  131.                             {
  132.                                 if(lines)
  133.                                 {
  134.                                     node->Special.Button.KeyStroke = &label[i];
  135.  
  136.                                     lines = NULL;
  137.                                 }
  138.                                 else
  139.                                 {
  140.                                     STRPTR newLabel;
  141.  
  142.                                     if(newLabel = LTP_Alloc(handle,len + 2))
  143.                                     {
  144.                                         node->Label = newLabel;
  145.  
  146.                                         if(i)
  147.                                             CopyMem(label,newLabel,i);
  148.  
  149.                                         newLabel[i] = '_';
  150.  
  151.                                         strcpy(&newLabel[i + 1],label + i);
  152.                                     }
  153.                                 }
  154.  
  155.                                 node->Key = code;
  156.  
  157.                                 handle->Keys[code] = handle->Keys[LTP_Keys[1][code]] = TRUE;
  158.  
  159.                                 break;
  160.                             }
  161.                         }
  162.                     }
  163.                     while(lines);
  164.                 }
  165.  
  166.                 break;
  167.         }
  168.     }
  169. }
  170. #endif
  171.